Skip to content

Conversation

@marsfan
Copy link

@marsfan marsfan commented Nov 9, 2025

For my own reference, I added type hints to this library, and figured that it might be nice to upstream them to you.

Also, while doing this, I also found one place with a minor code error (trying to call .hex() on a string instead of bytes) and a few places that did not double check that values were not None before proceeding, so I fixed those up. I took care to not otherwise change the actual code, or even the formatting.

Adding type hints makes it easier to understand what the expected inputs and outputs of the code is, and has the added benefit of allowing the use of mypyc or cython to generate a C based library from the Python code. In testing, I found that uses either one of them leads to a decent performance improvement (the test script went from taking about 90 seconds to taking about 60 seconds).

One downside is that the use of the types-docopt module means I had to restrict the minimum Python version to 3.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant